{extend name="_container/table"}
{block name="left"}
<style>
  .dropbtn{
    height: 38px;
    line-height: 38px;
    border: 1px solid transparent;
    padding: 0 18px;
    background-color: #009688;
    color: #fff;
    white-space: nowrap;
    text-align: center;
    font-size: 14px;
    border-radius: 2px;
    cursor: pointer;
  }
  .dropdown-content {
    display: none;
    position: absolute;
    background-color: #FFF;
    width: 100%;
    overflow: auto;
    z-index: 100;
  }

  .show {
    display:flex;
    justify-content: flex-end;
    right: 150px;
    top: 30px;
    height: 50px;
    background-color: #FFF;
  }

</style>
<!--<a href="{:url('add')}" class="layui-btn  iframe" data-title="添加表">添加表</a>-->
<span data-href="{:url('auto/configClass/index')}" class="layui-btn layui-btn-radius iframe" style="background-color: #607d8b" data-title="系统配置" data-width="100%" data-height="100%">系统配置</span>

<a href="{:url('fastAdd')}" class="layui-btn  iframe" data-title="快速添加" data-height="100%" data-width="100%">添加表</a>
<a href="{:url('relation/index')}" class="layui-btn layui-btn-normal  iframe" data-title="关联关系" data-width="100%" data-height="100%">关联关系</a>
<a href="{:url('auto/table/generate')}" class="layui-btn  layui-btn-warm ajax_del" data-msg="确定生成代码吗？">生成代码</a>
{/block}

{block name="right"}
<div style="position: absolute;display: flex;left: 40%">

  {foreach $apps as $app}
<span data-href="{:url('controller/index',['app_id'=>$app.id])}" class="layui-btn layui-btn-radius iframe" style="background-color: #651fff" data-title="{$app.name}应用控制器列表" data-width="100%" data-height="100%">{$app.name}</span>
{/foreach}
<span data-href="{:url('auto/app/index')}" class="layui-btn layui-btn-radius iframe" style="background-color: #607d8b" data-title="应用管理" data-width="100%" data-height="100%">应用管理</span>
</div>
<div class="dropbtn" id="down-menu" onclick="myFunction()">
  <-更对功能
  <div id="myDropdown" class="dropdown-content"  >
    <span data-href="{:url('DbDoc/index')}" class="layui-btn  iframe" data-title="dbDoc" data-width="100%" data-height="100%">dbDoc</span>
    <span data-href="{:url('faker/index')}" class="layui-btn  iframe" data-title="模拟数据" data-width="100%" data-height="100%">模拟数据</span>
    <span data-href="{:url('v6')}" class="layui-btn  iframe" data-title="v6" data-width="100%" data-height="100%">v6</span>
    <span data-href="/apidoc" class="layui-btn  iframe" data-title="apiDoc" data-width="100%" data-height="100%" >apiDoc</span>
    <span data-href="{:url('Translate/index')}" class="layui-btn  iframe" data-title="翻译管理" data-width="100%" data-height="100%">翻译</span>
    <span data-href="{:url('deleteAll')}" class="layui-btn  layui-btn-danger ajax_del" data-msg="确定要清空表吗？">清空表</span>
  </div>
</div>


{/block}

{block name="table_header"}
<th>id</th>
<th>表名</th>
<th>表注释</th>
<th>自动时间</th>
<th>软删除</th>
<th>公共序号</th>
<th>排序</th>
<th>树形排序</th>

<th>操作</th>
{/block}

{block name="table_body"}
<tr>
<td>{$v.id}</td>
<td>{$v.name}</td>
<td>{$v.comment}</td>
<td>
  <input type="checkbox" lay-text="是|否"  lay-skin="switch" value="1"  {$v.is_auto_time?'checked':''} name="is_auto_time" data-id="{$v.id}" >
</td>
<td>
  <input type="checkbox" lay-text="是|否"  lay-skin="switch" value="1"  {$v.is_soft_delete?'checked':''} name="is_soft_delete" data-id="{$v.id}" >
</td>
<td>
  <input type="checkbox" lay-text="是|否"  lay-skin="switch" value="1"  {$v.is_pubid?'checked':''} name="is_pubid" data-id="{$v.id}" >
</td>
<td>
  <input type="checkbox" lay-text="是|否"  lay-skin="switch" value="1"  {$v.is_sort?'checked':''} name="is_sort" data-id="{$v.id}" >
</td>
<td>
  <input type="checkbox" lay-text="是|否"  lay-skin="switch" value="1"  {$v.is_tree_sort?'checked':''} name="is_tree_sort" data-id="{$v.id}" >
</td>

<td>
  <a href="{:url('field/index',['table_id'=>$v.id])}" class="layui-btn layui-btn-sm  iframe" data-width="100%" data-height="100%" data-title="{$v.comment}表字段">字段</a>
  <a href="{:url('delete',['id'=>$v.id])}" class="layui-btn layui-btn-sm layui-btn-danger ajax_del">删除</a>
  {if $v.controller_id}
  <a href="{:url('method/index',['controller_id'=>$v.controller_id])}" class="layui-btn layui-btn-radius layui-btn-sm  iframe" style="background-color: #651fff" data-width="100%" data-height="100%" data-title="{$v.comment}方法列表">admin方法</a>
  {/if}
</td>
</tr>
{/block}

{block name="table_footer"}
{/block}

{block name="js"}
<script>
  let form = layui.form;
  form.on('switch', function (data){
    let name = data.elem.name;
    let checked = data.elem.checked;
    let is_show = checked ? 1 : 0;
    if(name === 'is_auto_time'){
      let id = $(data.elem).data('id');
      $.post("{:url('setSysField')}",{id, is_show, name},(res)=>{
        layer.msg(res.msg)
      })
    }
    if(name === 'is_soft_delete'){
      let id = $(data.elem).data('id');
      $.post("{:url('setSysField')}",{id, is_show, name},(res)=>{
        layer.msg(res.msg)
      })
    }
    if(name === 'is_pubid'){
      let id = $(data.elem).data('id');
      $.post("{:url('setSysField')}",{id, is_show, name},(res)=>{
        layer.msg(res.msg)
      })
    }
    if(name === 'is_sort'){
      let id = $(data.elem).data('id');
      $.post("{:url('setSysField')}",{id, is_show, name},(res)=>{
        layer.msg(res.msg)
      })
    }
    if(name === 'is_tree_sort'){
      let id = $(data.elem).data('id');
      $.post("{:url('setSysField')}",{id, is_show, name},(res)=>{
        layer.msg(res.msg)
      })
    }
  })
</script>

<script>
  /* 点击按钮，下拉菜单在 显示/隐藏 之间切换 */
  function myFunction() {
    document.getElementById("myDropdown").classList.toggle("show");
  }

  // 点击下拉菜单意外区域隐藏
  window.onclick = function(event) {
    if (!event.target.matches('.dropbtn')) {

      var dropdowns = document.getElementsByClassName("dropdown-content");
      var i;
      for (i = 0; i < dropdowns.length; i++) {
        var openDropdown = dropdowns[i];
        if (openDropdown.classList.contains('show')) {
          openDropdown.classList.remove('show');
        }
      }
    }
  }
</script>
{/block}
{/extend}
